﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ELTE.SEM.Data.ViewModels
{
    public class SemFolderViewModel
    {
        public int Id { get; set; }
        public string FolderName { get; set; }
        public List<SemFolderViewModel> Children { get; set; }
        public SemFolderViewModel Parent { get; set; }
        public string FullPath { get; set; }

        public string GetPath()
        {
            SemFolderViewModel root = this;
            List<SemFolderViewModel> folderChain = new List<SemFolderViewModel>();
            folderChain.Add(this);
            while (root != null && root.Parent != null)
            {
                root = root.Parent;
                folderChain.Add(root);
            }
            folderChain.Reverse();
            StringBuilder builder = new StringBuilder();
            foreach (SemFolderViewModel item in folderChain)
            {
                builder.Append("/" + item.FolderName);
            }
            return builder.ToString();
        }
    }
}
